home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / grafica / amhelios / view_sys.h < prev    next >
C/C++ Source or Header  |  1999-01-01  |  6KB  |  153 lines

  1. ////////////////////////////////////////////////////////////
  2. //
  3. //  VIEW_SYS.H - Viewing System Class Include File
  4. //
  5. //  Version:    1.03A
  6. //
  7. //  History:    94/08/23 - Version 1.00A release.
  8. //              94/12/16 - Version 1.01A release.
  9. //              94/12/24 - Added par_flag and scale data
  10. //                         members.
  11. //                       - Added GetParProjFlag,
  12. //                         GetWindowScale, SetParProjFlag,
  13. //                         and SetWindowScale functions.
  14. //              95/02/05 - Version 1.02A release.
  15. //              95/07/21 - Version 1.02B release.
  16. //              96/02/14 - Version 1.02C release.
  17. //              96/03/30 - Added InitViewSystem function
  18. //                         prototype.
  19. //                       - Added "environ.h" include
  20. //                         directive.
  21. //                       - Added VS_FILL_FACTOR definition.
  22. //                       - Added efd, tilt_angle, cvu and
  23. //                         focus_posn data members.
  24. //                       - Added GetFocusPosn, SetFocusPosn,
  25. //                         GetTiltAngle and SetTiltAngle
  26. //                         functions.
  27. //                       - Added Dolly, Orbit, Pan, Rotate,
  28. //                         Tilt, Zoom and SetEyeFocusPosn
  29. //                         function prototypes.
  30. //                       - Modified ViewSys constructor to
  31. //                         initialize focus_posn, cvu, efd
  32. //                         and tilt_angle.
  33. //                       - Deleted GetViewDir, GetViewUp,
  34. //                         SetViewDir and SetEyePosn
  35. //                         functions.
  36. //              96/04/01 - Version 1.03A release.
  37. //
  38. //  Compilers:  Microsoft Visual C/C++ Professional V1.5
  39. //              Borland C++ Version 4.5
  40. //
  41. //  Author:     Ian Ashdown, P.Eng.
  42. //              byHeart Software Limited
  43. //              620 Ballantree Road
  44. //              West Vancouver, B.C.
  45. //              Canada V7S 1W3
  46. //              Tel. (604) 922-6148
  47. //              Fax. (604) 987-7621
  48. //
  49. //  Copyright 1994-1996 byHeart Software Limited
  50. //
  51. //  The following source code has been derived from:
  52. //
  53. //    Ashdown, I. 1994. Radiosity: A Programmer's
  54. //    Perspective. New York, NY: John Wiley & Sons.
  55. //
  56. //  It may be freely copied, redistributed, and/or modified
  57. //  for personal use ONLY, as long as the copyright notice
  58. //  is included with all source code files.
  59. //
  60. ////////////////////////////////////////////////////////////
  61.  
  62. #ifndef _VIEW_SYS_H
  63. #define _VIEW_SYS_H
  64.  
  65. #include "patch3.h"
  66. #include "environ.h"
  67.  
  68. // Extents fill factor
  69. static const double VS_FILL_FACTOR = 0.9;
  70.  
  71. class ViewSys           // Viewing system
  72. {
  73.   private:
  74.     BOOL par_flag;      // Parallel projection flag
  75.     double bpd;         // Back plane distance
  76.     double eye;         // View distance
  77.     double efd;         // Eye-focus distance
  78.     double fpd;         // Front plane distance
  79.     double scale;       // Window scale
  80.     double tilt_angle;  // Tilt angle (degrees)
  81.     Point3 origin;      // View space origin
  82.     Point3 eye_posn;    // Eye position
  83.     Point3 focus_posn;  // Focus position
  84.     Vector3 cvu;        // Canonical view-up vector
  85.     Vector3 vdv;        // View direction vector
  86.     Vector3 vuv;        // View-up vector
  87.     double ptm[4][4];   // Projective transformation matrix
  88.  
  89.   protected:
  90.     double aspect;      // Aspect ratio
  91.  
  92.     BOOL BackFaceCull( Patch3 *);
  93.     double (*GetProjMatrix())[4];
  94.     void BuildTransform();
  95.  
  96.   public:
  97.     ViewSys()
  98.     {
  99.       par_flag = FALSE;
  100.       aspect = 1.0;
  101.       fpd = -0.99;
  102.       bpd = 10000.0;
  103.       eye = -1.0;
  104.       efd = 1.0;
  105.       scale = 1.0;
  106.       tilt_angle = 0.0;
  107.       eye_posn = Point3(-1.0, 0.0, 0.0);
  108.       focus_posn = Point3(0.0, 0.0, 0.0);
  109.       origin = Point3(0.0, 0.0, 0.0);
  110.       cvu = Vector3(0.0, 0.0, 1.0);
  111.       vdv = Vector3(-1.0, 0.0, 0.0);
  112.       vuv = Vector3(0.0, 0.0, 1.0);
  113.  
  114.       BuildTransform();         // Initialize matrix
  115.     }
  116.  
  117.     BOOL GetParProjFlag() { return par_flag; }
  118.     double GetBackDist() { return bpd; }
  119.     double GetFrontDist() { return fpd; }
  120.     double GetTiltAngle() { return tilt_angle; }
  121.     double GetWindowScale() { return scale; }
  122.     double GetViewDist() { return -eye; }
  123.     Point3 &GetEyePosn() { return eye_posn; }
  124.     Point3 &GetFocusPosn() { return focus_posn; }
  125.     Point3 &GetOrigin() { return origin; }
  126.     void Dolly( double );
  127.     void InitViewSystem( Environ * );
  128.     void Orbit( double, double );
  129.     void Pan( double, double );
  130.     void Rotate( double, double );
  131.     void SetBackDist( double b ) { bpd = b; }
  132.     void SetEyeFocusPosn( Point3 &, Point3 & );
  133.     void SetFrontDist( double f ) { fpd = f; }
  134.     void SetOrigin( Point3 &o ) { origin = o; }
  135.     void SetParProjFlag( BOOL f ) { par_flag = f; }
  136.     void SetTiltAngle( double t ) { tilt_angle = t; }
  137.     void SetViewDist( double e ) { eye = -e; }
  138.     void SetViewUp( Vector3 & );
  139.     void SetWindowScale( double s ) { scale = s; }
  140.     void Tilt( double );
  141.     void Zoom( double );
  142.     Vector3 &GetLRVector() { Vector3 v; v = Cross(vdv,cvu); return v; }
  143.     void DollyEyeFocusPosn( double, double );
  144.     void CopyViewSys(ViewSys &sys) { double a; a=sys.aspect; sys = *this; sys.aspect=a; sys.BuildTransform(); }
  145. };
  146.  
  147. // Return projective transformation matrix pointer
  148. inline double (*ViewSys::GetProjMatrix())[4]
  149. { return ptm; }
  150.  
  151. #endif
  152.  
  153.